<%@page import="systems.AdsSystem"%>
<%@page import="entities.Author"%>
<%@page import="models.AuthorModel"%>
<%@page import="systems.RecentlyAuthorUpdate"%>
<%@page import="entities.Category"%>
<%@page import="models.CategoryModel"%>
<%@page import="entities.Question"%>
<%@page import="models.QuestionModel"%>
<%@page import="systems.RecentlyUpdate"%>
<%@page import="java.util.List"%>
<%
//Get Lastest question
List<Question> lastestQuestion = RecentlyUpdate.getQuestions();

//Get categories
CategoryModel categoryModel = CategoryModel.getInstance();
List<Category> categories = categoryModel.getAll();

//Get recently author update
List<Author> authors = RecentlyAuthorUpdate.getAuthors();

%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

			<div class="span4 slidebar">
				<div class="slidebarbox">
					<h2>Categories</h2>
					<div>
						<ul class="list-item">
						<% for (Category category : categories) { %>
						<li><a href="/category/<%=category.getAlias()%>-<%=category.getId()%>"><%=category.getName() %></a></li>
						<% } %>
						</ul>
					</div>
				</div>
				
				<div class="slidebarbox">
					<h2>Lastest Question</h2>
					<ul class="list-item">
						<% 
						for (int i = 0 ; i < lastestQuestion.size(); i++) { 
							if (i >= 5) break;
						%>
						<li>
							<span class="questioncount"><%=lastestQuestion.get(i).getAnswers().size() %></span>
							<a href="/question/<%=lastestQuestion.get(i).getId()%>/<%=lastestQuestion.get(i).getUrl()%>"><%=lastestQuestion.get(i).getTitle() %></a>
						</li>
						<% } %>
					</ul>
				</div>
				
				<div class="slidebarbox">
					<h2>Lastest Authors</h2>
					<ul class="list-item">
						<% 
						for (int i = 0; i < authors.size(); i++) { 
							if (i >= 5) break;
						%>
						<li>
							<a href="/author/<%=authors.get(i).getAlias()%>-<%=authors.get(i).getId()%>">
								<img height="22" width="22" src="<%=authors.get(i).getAvatar()%>" class="avatar">
								<%=authors.get(i).getName() %>
							</a>
						</li>
						<% } %>
					</ul>
				</div>
			</div>